package com.vf.admin.utils.chouJiang;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class TestLottery {
    static final int TIME = 1;

    public static Result iteratorMap(Map<Integer, Integer> map, List<Double> list){
        Result result=new Result();
        for(Map.Entry<Integer, Integer> entry : map.entrySet()){
            int index = entry.getKey();
            int time  = entry.getValue();
            result = new Result(index, TIME, time, list.get(index));
        }
        return result;

    }

    public static void main(String[] args) {
        //构造概率集合
      /*  String sss="0.001";
        Double dd=Double.parseDouble(sss);
        System.out.println(dd);*/
        Double a=0.00;
        Double b=0.00;
        Double c=0.00;
        Double d=0.00;
        Double e=0.00;
        Double f=0.00;
        Double g=0.01;
        List<Double> list = new ArrayList<Double>();
     /*   Result chou=new Result();
        chou.setIndex(1);
        chou.setRealProbability(000000);
*/
        list.add(a);

        list.add(b);
        list.add(c);
        list.add(d);
        list.add(e);
        list.add(f);
        list.add(g);

        LotteryUtil ll = new LotteryUtil(list);
        double sumProbability = ll.getMaxElement();

        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        for(int i = 0; i < TIME; i++){
            int index = ll.randomColunmIndex();
            if(map.containsKey(index)){
                map.put(index, map.get(index) + 1);
            }else{
                map.put(index, 1);
            }
        }
        for(int i = 0; i < list.size(); i++){
            double probability = list.get(i) / sumProbability;
            list.set(i, probability);
        }
        iteratorMap(map, list);
        System.out.println(iteratorMap(map, list).getIndex());

    }


}
